|
|
 |
|
|
|
|
'With oReg
' txtKeyValue = .KeyGet(txtSection, _
txtKeyName, _
"")
'End With
Set oReg = Nothing
End Sub |
|
|
|
|
|
|
|
|
Notice that at the end of this routine I have commented out an alternate way to get databy passing all the relevant information directly to the KeyGet() method. |
|
|
|
|
|
|
|
|
This code should look very familiar to youits exactly the same as the code in the INI example, except for the name of the class. |
|
|
|
|
|
|
|
|
The KeyGet() Method of the Registry Class |
|
|
|
|
|
|
|
|
The KeyGet() method in the Registry class accepts optional arguments for the section name, the key name, and the default value (in case you dont find the value youre after). Notice that each of the optional arguments has a default value. You can check each of the arguments against their default values to see whether any have been passed into the method. If any have been passed in, you need to override the module-level variable that corresponds to the argument. After all the module-level variables are set, you then call the GetSetting() method to return the data value back to the mstrKeyValue variable. Heres the code: |
|
|
|
 |
|
|
|
|
Public Function KeyGet( _
Optional strSection As String = "NA", _
Optional strKeyName As String = "NA", _
Optional strDefault As String = "") _
As String
' Fill in properties
If strSection <> "NA" Then
mstrSection = strSection
End If
If strKeyName <> "NA" Then
mstrKeyName = strKeyName
End If
mstrDefault = strDefault |
|
|
|
|
|